<html>
<body>





<form method="POST" action="query.php">
<TEXTAREA NAME="query" ROWS=5 COLS=50>
</TEXTAREA>
<INPUT TYPE="submit" VALUE="submit"/>
</form>


<?php

$db_connection = mysql_connect("localhost", "cs143", "");

mysql_select_db("CS143", $db_connection);

$query="";
$query=$_POST["query"];


$sanitized_name=mysql_real_escape_string($query, $db_connection);
$rs=mysql_query($query, $db_connection);

if(!$rs) {
die(mysql_error());
}
$numfields = mysql_num_fields($rs);


echo "<table border= '1'>

<tr>";

for($i=0; $i<$numfields; $i++)
{
 echo "<th>".mysql_field_name($rs,$i)."</th>";

}
echo "</tr>";

while($row = mysql_fetch_row($rs)) 
{
    echo "<tr>";
    for($i=0; $i < $numfields; $i++ )
    {
    	echo"<td>"."$row[$i]"."</td>";
    }

    echo "</tr>";
    for($i=0; $i < $numfields; $i++)
    {
	
    }
    

}
echo "</table>";

mysql_close($db_connection);

?>


</body>
</html>